<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
%>
<jsp:include page="/comm/header.jsp"></jsp:include>
<script src="<%= path%>/script/jquery-1.4.2.min.js" ></script>
<div class="clear"></div>
<!--第1部分开始  -->
<div class="wrap1">
	<div class="blank1"></div>
	<!--选项卡开始-->
	<div id="mainTabbox">
		<jsp:include page="../tabboxhead.jsp" />
		<div id="conten">
			<div class="tab_show" id="con_tabmy_1">
				<jsp:include page="left.jsp"></jsp:include>
				<div class="wrap_left">
					<div class="wrap_m2">
						<!--财务信息开始-->
						<div id="tip"><s:property value="tipMessage"/></div>
						<div class="outbox4">
							<div class="tab7_tt">财务信息</div>
							<div class="input_box">
							 <s:if test="accountModel.accountType==0">
								 为了您的交易安全，财务信息一旦填写，将不再允许修改，请慎重填写!
							</s:if>	 
							<s:else>
								您的财务信息已经填写，如果需要修改，请联系客服人员!
							</s:else>
								<ul>
									<li class="t1"><span class="span33">请选择支付方式：</span></li>
									<li class="t2">
									<s:if test="accountModel.accountType==0">
									<s:radio id="accountType"  name="accountType" list="#{'1':'支付宝' , '2':'银行转账'}" value="1"  onclick="selectAccountType(this.value)" theme="simple" />
									</s:if>
									<s:else>
									<s:radio id="accountType"  name="accountType" list="#{'1':'支付宝' , '2':'银行转账'}" value="accountModel.accountType" disabled="true"  onclick="selectAccountType(this.value)" theme="simple" />
									</s:else>
									</li>
								</ul>
							</div>

							<div id="alipay"  <s:if test="accountModel.accountType==2"> style="display:none" </s:if> >
								<form name="saveAccount1" action="<%=path%>/user/saveAccount.htm" method="post">
								<div class="input_box">
									<ul>
										<li class="t1"><span class="span33">* 支付宝账号：</span></li>
										<li class="t2">
											<input type="hidden" name="accountModel.accountType" value="1" />
											<s:if test='accountModel.accountType==0'>
											<s:textfield id="alipayid" name="accountModel.alipayid"  cssClass="input1"/><span id="alipay_msg"></span>
											</s:if>
											<s:else>
											<s:textfield id="alipayid" name="accountModel.alipayid" disabled="true"  cssClass="input1"/>
											</s:else>
											</li>
									</ul>
								</div>
								<div class="clear"></div>
								<s:if test="accountModel.accountType==0">
								<div class="but_submit" style="text-align: left;  margin: 30px 0 30px 130px">
									<a href="#" onclick="alipayCheck()">保存</a>&nbsp;&nbsp;&nbsp;
								</div>
								</s:if>
								</form>
								
							</div>

							<div id="bank" <s:if test="accountModel.accountType!=2"> style="display:none" </s:if>>
								<form name="saveAccount2" action="<%=path%>/user/saveAccount.htm" method="post">
								<div class="input_box">
									<ul>
										<li class="t1"><span class="span33">* 身份证号：</span></li>
										<li class="t2"><input type="hidden" name="accountModel.accountType" value="2" />
										<s:if test="accountModel.accountType==0">
										<s:textfield id="idcard" name="accountModel.idcard" cssClass="input1"/><span id="idcard_msg"></span>
										</s:if>
										<s:else>
										<s:textfield id="idcard" name="accountModel.idcard" disabled="true" cssClass="input1"/>
										</s:else>
										</li>

										<li class="t1"><span class="span33">* 开户银行：</span></li>
										<li class="t2">
										<s:if test="accountModel.accountType==0">
										<s:textfield id="bankName" name="accountModel.bankName" cssClass="input1"/><span id="bankName_msg"></span>
										</s:if>
										<s:else>
										<s:textfield id="bankName" name="accountModel.bankName" disabled="true" cssClass="input1"/>
										</s:else>
										</li>
										
										<li class="t1"><span class="span33">* 银行帐号：</span></li>
										<li class="t2">
										<s:if test="accountModel.accountType==0">
										<s:textfield id="bankAccountID" name="accountModel.bankAccountID" cssClass="input1"/><span id="bankAccountID_msg"></span>
										</s:if>
										<s:else>
										<s:textfield id="bankAccountID" name="accountModel.bankAccountID" disabled="true" cssClass="input1"/>
										</s:else>
										
										</li>
										<li class="t1"><span class="span33">* 开户人：</span></li>
										<li class="t2">
										<s:if test="accountModel.accountType==0">
										<s:textfield id="bankAccountName" name="accountModel.bankAccountName" cssClass="input1"/><span id="bankAccountName_msg"></span>
										</s:if>
										<s:else>
										<s:textfield id="bankAccountName" name="accountModel.bankAccountName" disabled="true" cssClass="input1"/>
										</s:else>
										</li>
									</ul>
								</div>
								<div class="clear"></div>
								<s:if test="accountModel.accountType==0">
									<div class="but_submit" style="text-align: center; margin: 30px 0">
										<a href="#" onclick="bankCheck()">保存</a>&nbsp;&nbsp;&nbsp;
									</div>
								</s:if>
								</form>
							</div>
							<div class="clear"></div>
						</div>
						<!--财务信息结束-->
					</div>
				</div>
				<div class="clear"></div>

				<!--内容结束-->

			</div>

		</div>
	</div>
	<!--选项卡结束-->

</div>
</div>
<jsp:include page="/comm/bottom.jsp"></jsp:include>
</body>
</html>
<script type="text/javascript">
	function selectAccountType(radio){
		var paytype = radio;
		
		if(paytype==1){
			$("#bank").css("display","none");
			$("#alipay").css("display","");
		}else{
			$("#alipay").css("display","none");
			$("#bank").css("display","");
		}
	}
	
	function alipayCheck(){
		$("#alipay_msg").html("");
		
		var alipayid_val = $("#alipayid").val().replace(/(^\s*)|(\s*$)/g, "");
		var msgDisplay = "alipay_msg";
		//原密码不能为空
   		if(alipayid_val=='')
		{
   			$("#"+msgDisplay).html("<font color='red'>支付宝账号不能为空！</font>");
   			$("#alipayid").focus(); 
   			return false;
		}
		
   		if(!$("#alipayid").val().match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)){ 
   		    $("#"+msgDisplay).html("<font color='red'>支付宝格式不正确！请重新输入！</font>"); 
   		    $("#alipayid").focus(); 
   		    return false; 
   		} 
		document.saveAccount1.submit();
	}
	
	function bankCheck(){
		$("#idcard_msg").html("");
		$("#bankName_msg").html("");
		$("#bankAccountID_msg").html("");
		$("#bankAccountName_msg").html("");
		
		var idcard_val = $("#idcard").val().replace(/(^\s*)|(\s*$)/g, "");
		var bankName_val = $("#bankName").val().replace(/(^\s*)|(\s*$)/g, "");
		var bankAccountID_val = $("#bankAccountID").val().replace(/(^\s*)|(\s*$)/g, "");
		var bankAccountName_val = $("#bankAccountName").val().replace(/(^\s*)|(\s*$)/g, "");
		
		if(idcard_val=='')
		{
	   		$("#idcard_msg").html("<font color='red'>身份证号码不能为空!</font>");
	   		$("#idcard").focus(); 
	   		return false;
		}
		
		if(idcard_val.length!=18){
			$("#idcard_msg").html("<font color='red'>身份证号码输入错误!</font>");
	   		$("#idcard").focus(); 
	   		return false;
		}
		
		if(bankName_val=='')
		{
	   		$("#bankName_msg").html("<font color='red'>开户银行不能为空!</font>");
	   		$("#bankName").focus(); 
	   		return false;
		}
		
		if(bankName_val.length<16){
			$("#bankName_msg").html("<font color='red'>开户银行输入错误!</font>");
	   		$("#bankName").focus(); 
	   		return false;
		}
		
		if(bankAccountID_val=='')
		{
	   		$("#bankAccountID_msg").html("<font color='red'>银行账户不能为空!</font>");
	   		$("#bankAccountID").focus(); 
	   		return false;
		}
		
		if(bankAccountID_val.length<17 || bankAccountID_val.length>20){
			$("#bankAccountID_msg").html("<font color='red'>银行账户输入错误!</font>");
	   		$("#bankAccountID").focus(); 
	   		return false;
		}
		
		if(bankAccountName_val=='')
		{
	   		$("#bankAccountName_msg").html("<font color='red'>开户人不能为空!</font>");
	   		$("#bankAccountName").focus(); 
	   		return false;
		}
		
		if(bankAccountName_val.length<4)
		{
	   		$("#bankAccountName_msg").html("<font color='red'>开户人输入错误!</font>");
	   		$("#bankAccountName").focus(); 
	   		return false;
		}
		
		document.saveAccount2.submit();
	}
</script>
